/*
 * Copyright 2013 Agustina Martinez-Garcia

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
 */
package uk.ljmu.qudexapps.xmllib.utilities;

import java.io.Serializable;

/**
 * Class to manage the results of the repository operations performed
 * 
 * @author agustinamartinez
 * 
 */
public class IngestionResults implements Serializable {
    /**
     * 
     */
    private static final long serialVersionUID = 7327528414883046314L;
    /**
     * Generated PID for the object stored in the repository
     */
    private String generatedObjectPID;
    /**
     * Any useful status messages coming from Fedora regarding the process of
     * ingestion of objects
     */
    private String ingestionStatus;
    /**
     * In Fedora threw a error page in XML then is stored here to support custom
     * error page display
     */
    private String xmlErrorPage;

    public IngestionResults(String identifier, String status) {
	super();
	generatedObjectPID = identifier;
	ingestionStatus = checkStatus(status);
    }

    private String checkStatus(String status) {
	// Check if errors
	for (String key : Constants.fedoraErrorCodes.keySet()) {
	    if (status.contains(key)) {
		return Constants.fedoraErrorCodes.get(key);
	    }
	}
	return status;
    }

    /**
     * @param generatedObjectPID
     *            the generatedObjectPID to set
     */
    public void setGeneratedObjectPID(String generatedObjectPID) {
	this.generatedObjectPID = generatedObjectPID;
    }

    /**
     * @return the generatedObjectPID
     */
    public String getGeneratedObjectPID() {
	return generatedObjectPID;
    }

    /**
     * @param ingestionStatus
     *            the ingestionStatus to set
     */
    public void setIngestionStatus(String ingestionStatus) {
	this.ingestionStatus = ingestionStatus;
    }

    /**
     * @return the ingestionStatus
     */
    public String getIngestionStatus() {
	return ingestionStatus;
    }

    /**
     * @param xmlErrorPage
     *            the xmlErrorPage to set
     */
    public void setXmlErrorPage(String xmlErrorPage) {
	this.xmlErrorPage = xmlErrorPage;
    }

    /**
     * @return the xmlErrorPage
     */
    public String getXmlErrorPage() {
	return xmlErrorPage;
    }

}